//logs.js
const util = require('../../utils/util.js')
const auth = require('../../utils/auth.js')
Page({
  data: {
    imageUrl:'',
    holidayChineseName:'',
    holidayEnglishName:'',
    holidayTime:'',
    holidayIntroduce:'',
    collectionStatus: true,
      couponImg:{
      couponTrue:'../../img/holiday-true.png',
      couponFalse:'../../img/holiday-false.png'
    },
    id:'',
    loading:false
  },
  onLoad: function (options) {
    var that = this;
    var id = options.id;
    that.setData({
       id:id
    });
    util.ajax({
      url:'act/actapi/detail',
      data: {
        id:id
    },
    header: {
      'content-type': 'application/json' // 默认值
    },
      success: function(res) {
        var collStatus = res.data.is_collect;
        var res = res.data;
        that.setData({
          holidayChineseName:res.title,
          holidayIntroduce:res.content,
          holidayTime:res.date,
          holidayEnglishName:res.en_title,
          loading:true,
          imageUrl:res.face_url
        });       
        if(collStatus){
            that.setData({
              collectionStatus:false
            });
         }else{
            that.setData({
               collectionStatus:true
            }); 
         }
      }
    })
  },
  durationChange: function(e) {
    this.setData({
      duration: e.detail.value
    })
  },
  /**
   * 收藏
   */
  turn: function (e) {
    wx.showToast({
      title: '已收藏',
      duration: 1000
    })
    this.setData({
      collectionStatus:false
    })
    var that=this;
    util.ajax({
      url: 'act/actapi/collect',
      data: {
          id:that.data.id,
          collect:1
      },
      header: {
          'content-type': 'application/json' // 默认值
      },
      success: function(res) {

      }
    })
  },
  back :function (e){
    wx.showToast({
      title: '已取消收藏',
      duration: 1000
    })
    this.setData({
      collectionStatus: true
    })
    var that=this;
     util.ajax({
      url: 'act/actapi/collect',
      data: {
          id:that.data.id,
          collect:2
      },
      header: {
          'content-type': 'application/json' // 默认值
      },
      success: function(res) {

      }
    })
  }
})
